package cn.edu.cqupt.cxcy.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 检查 验证码
 * @author Dancer-mno
 * @date 2015年10月17日
 */
public class AjaxCodeCheck extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}
	
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String name = request.getParameter("name");//获得ajax传的值
		boolean re = false;/*存在就返回false,可以使用就返回true*/
		if(name == null || name.equals("")) {
			
		} else if(((String)request.getSession().getAttribute("safecode")).equalsIgnoreCase(name)) {
			re = true;
		}
		PrintWriter out = response.getWriter();
		out.println(re);
		out.flush();
	}

}
